사이트 내 전체검색
링크가 걸린 URL 에서 링크의 도메인 추출(제거)하기
로빈아빠
https://cmd.kr/javascript/864 URL이 복사되었습니다.

본문

[code]

$buff="...
href = 'https://goyangnews.com/bbs/board.php?bo_table=society&wr_id=8
href =\"http://goyangnews.com/bbs/board.php?bo_table=society&wr_id=8\"
href='http://goyangnews.co.kr/bbs/board.php?bo_table=society&wr_id=8
href='https://goyangnews.kr//bbs/board.php?bo_table=society&wr_id=8
https://goyangnews.zz

";

preg_match_all("/['|\"]((https|http):?\/\/[-a-z0-9.]*)/is", $buff,$match);
var_dump($match);

[/code]

링크가 걸린 URL 에서 도메인 추출(제거)하기

array(3) {
  [0]=>
  array(4) {
    [0]=>
    string(23) "'https://goyangnews.com"
    [1]=>
    string(22) ""http://goyangnews.com"
    [2]=>
    string(24) "'http://goyangnews.co.kr"
    [3]=>
    string(22) "'https://goyangnews.kr"
  }
  [1]=>
  array(4) {
    [0]=>
    string(22) "https://goyangnews.com"
    [1]=>
    string(21) "http://goyangnews.com"
    [2]=>
    string(23) "http://goyangnews.co.kr"
    [3]=>
    string(21) "https://goyangnews.kr"
  }
  [2]=>
  array(4) {
    [0]=>
    string(5) "https"
    [1]=>
    string(4) "http"
    [2]=>
    string(4) "http"
    [3]=>
    string(5) "https"
  }
}


링크에 포함된 도메인을 없애려면
if (preg_match_all("/['|\"]((https|http):?\/\/[-a-z0-9.]*)/is",$content,$match)&&$match[1]) {
$content=str_replace($match[1],'',$content);
}



출처 : 하우코드 로빈아빠 김성대

댓글목록

등록된 댓글이 없습니다.

831 (1/17P)

Search

Copyright © Cmd 명령어 3.138.174.195